package com.onpositive.realmview.basic;

import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import com.onpositive.semantic.model.api.command.ICommandExecutor;
import com.onpositive.semantic.model.api.property.ICommandFactory;
import com.onpositive.semantic.model.api.property.IProperty;
import com.onpositive.semantic.model.api.property.IPropertyLookup;
import com.onpositive.semantic.model.api.property.IPropertyMetaData;

public class ProxyMapProperty implements IProperty {
	
	private final String id;
	private final Class<?> subjectClass;
	private final IPropertyMetaData propertyMetaData;
	private final Map<String, Object> propertyMap;

	public ProxyMapProperty(String id, Class<?> subjectClass, IPropertyMetaData propertyMetaData, Map<String,Object> propertyMap) {
		this.id = id;
		this.subjectClass = subjectClass;
		this.propertyMetaData = propertyMetaData;
		this.propertyMap = propertyMap;
	}

	@Override
	public String getId() {
		return id;
	}

	@SuppressWarnings("unchecked")
	@Override
	public Class<Object> getSubjectClass() {
		return (Class<Object>) subjectClass;
	}

	@Override
	public Object getValue(Object obj) {
		return propertyMap.get(id);
	}

	@Override
	public IPropertyMetaData getPropertyMetaData() {
		return propertyMetaData;
	}

	@Override
	public boolean hasValue(Object obj) {
		return propertyMap.containsKey(id);
	}

	@Override
	public boolean hasValue(Object obj, Object value) {
		return propertyMap.containsKey(id);
	}

	@Override
	public Set<Object> getValues(Object obj) {
		return new HashSet<Object>(propertyMap.values());
	}

	@Override
	public ICommandFactory getCommandFactory() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public ICommandExecutor getCommandExecutor() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public IPropertyLookup getPropertyProvider() {
		// TODO Auto-generated method stub
		return null;
	}

}
